local jigou = fk.CreateSkill{
  name = "investiture__jigou",
}

Fk:loadTranslationTable{
  ["investiture__jigou"] = "机彀",
  [":investiture__jigou"] = "你使用牌后，若手牌数与使用此牌前相同，则你可移动场上的一张牌。",

  ["#investiture__jigou-move"] = "机彀：可以移动场上的一张牌",
}

jigou:addEffect(fk.CardUseFinished, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(jigou.name) and player == target
    and data.extra_data and player:getHandcardNum() == data.extra_data.investiture__jigou
  end,
  on_cost = function (self, event, target, player, data)
    local targets = player.room:askToChooseToMoveCardInBoard(player, {
      skill_name = jigou.name,
      cancelable = true,
      prompt = "#investiture__jigou-move",
      skip = true,
    })
    if #targets == 2 then
      event:setCostData(self, targets)
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    player.room:askToMoveCardInBoard(player, {
      target_one = event:getCostData(self)[1],
      target_two = event:getCostData(self)[2],
      skill_name = jigou.name,
    })
  end,
})

jigou:addEffect(fk.PreCardUse, {
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(jigou.name, true) and player == target
  end,
  on_refresh = function (self, event, target, player, data)
    data.extra_data = data.extra_data or {}
    data.extra_data.investiture__jigou = player:getHandcardNum()
  end
})

return jigou